package com.example.ruiji.controller.article;

import com.example.ruiji.service.article.ArticleServiceImpl;
import com.example.ruiji.service.category.CategoryServiceImpl;
import com.example.ruiji.utils.vo.Result;
import com.example.ruiji.utils.vo.param.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.yaml.snakeyaml.events.Event;

/**
 * Author:BaiYiChen
 * Date:2022/4/19 22:16
 *
 * @author BaiYiChen
 */
@RestController
@RequestMapping(value = "/articles")
public class ArticleController {
  @Autowired
  private ArticleServiceImpl articleService;
  
  @PostMapping("/view")
  public Result listArticle(PageParam param){
    return articleService.listArticle(param);
  }
  
  @PostMapping("/cnt")
  public Result listArticleCnt(){
    int cnt = articleService.articleCnt().intValue();
    return Result.successful(cnt);
  }
  @PostMapping("/cCnt")
  public Result listArticleCntByCategory(@RequestParam Integer cId){
    
    return articleService.listArticleByCategory(cId);
  }
  @GetMapping("/archived")
  public Result articleArch(){
    return articleService.articleArch();
  }
  
  @PostMapping("/showCategory")
  public Result showCategory(@RequestParam Integer id, PageParam param){
    Result category = articleService.listArticleById(id,param);
    return category;
  }
  
}
